package com.pxxy.toturial.service.impl;

import com.pxxy.toturial.service.CalcService;
import org.springframework.stereotype.Component;

/******************
 * @Author yejf
 * @Description TODO
 */
@Component
public class CalcServiceImpl implements CalcService {

    @Override
    public int add(int a, int b) {
        System.out.println("在 add 方法内部...");
        return a + b;
    }

    @Override
    public int subtract(int a, int b) {
        return a  - b;
    }

    @Override
    public double multiply(double a, double b) {
        return a * b;
    }

    @Override
    public double divide(double a, int b) {
        //模拟一个异常
        /*if(Math.random() < 0.05) {
            throw new RuntimeException("随机异常");
        }*/
        return a / b;
    }
}
